package com.tian.controller;

import com.tian.annotation.LoginCheckAnnotation;
import com.tian.common.CommonResult;
import com.tian.dto.user.UserCouponAddReqDto;
import com.tian.service.ChargeUserCouponSecondsKillService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * {@code @description:} 抢购优惠券控制器
 *
 * @author tianwc 公众号：Java后端技术全栈
 * 在线刷题 1200+java面试题和1000+篇技术文章：<a href="https://woaijava.cc/">博客地址</a>
 * {@code @date:} 2024-11-01 9:15
 * {@code @version:} 1.0
 */
@RestController
@RequestMapping("/api/user/coupon")
@Api(tags = "抢购优惠券 控制器")
public class UserCouponController {
    @Resource
    private ChargeUserCouponSecondsKillService chargeUserCouponSecondsKillService;
    @ApiOperation(value = "领取优惠券（抢购）", notes = "领取优惠券（抢购）")
    @ApiResponses({@ApiResponse(code = 200000, message = "操作成功")})
    @LoginCheckAnnotation
    @PostMapping("/seconds/kill")
    public CommonResult<Boolean> addSecondsKill(@RequestBody UserCouponAddReqDto userCouponAddReqDto) {
        return chargeUserCouponSecondsKillService.secondsKill(userCouponAddReqDto);
    }
}
